package com.qingyun.common.constant.factory;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qingyun.core.support.HttpKit;

import javax.servlet.http.HttpServletRequest;

/**
 * BootStrap Table默认的分页参数创建
 */
public class PageFactory<T> {

    public Page<T> defaultPage() {
        HttpServletRequest request = HttpKit.getRequest();
        int limit = Integer.valueOf(request.getParameter("limit"));
        int offset = Integer.valueOf(request.getParameter("offset"));
        Page<T> page = PageHelper.startPage((offset / limit + 1), limit,true);
        return page;
    }
}
